<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {

            width: 200px;
            height: 200px;
            background-color: red;
            transition: all 0.5s ease 0s;

        }
    </style>
</head>

<body>
    <div id="box"></div>
    <script>
        var box = document.getElementById('box');
        var xi = (box1, { x = 0, y = 0 }) => {
            box1.style.transform = `translate3d(${x}px,${y}px,0)`
        }
        document.onclick = () => {
            var gu = new Promise((resolve) => {
                xi(box, { x: 150 })
                resolve()
                console.log(0)
            }).then(() => {
              return  new Promise((resolve)=>{
                    xi(box,{x:150,y:150})
                    resolve()
                    console.log(1)
                })
        

            }).then(() => {
               console.log(2)
              return  xi(box, { y: 150 })
         
            }).then(() => {
                console.log(3)
            return        xi(box, { })
        
            })
        }

    </script>
</body>

</html>